﻿using System;
using System.Drawing.Design;
using System.Windows.Forms;

using Argos.Windows.Forms;

namespace Argos.Design
{
	public class UriTypeEditor : UITypeEditor
	{
		public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
		{
			using (UriEditorDialog dlg = new UriEditorDialog())
			{
				dlg.SelectedUri = value as Uri;

				if (dlg.ShowDialog() == DialogResult.OK)
				{
					return dlg.SelectedUri;
				}
			}

			return value;
		}

		public override UITypeEditorEditStyle GetEditStyle(System.ComponentModel.ITypeDescriptorContext context)
		{
			return UITypeEditorEditStyle.Modal;
		}
	}
}
